Drop _gdk_x11_set_input_focus_safe
authorMatthias Clasen <mclasen@redhat.com>
Sun, 27 Feb 2011 03:13:06 +0000 (22:13 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 27 Feb 2011 03:16:01 +0000 (22:16 -0500)
All that this function did was to asynchronously catch errors.
Since we have asynchronous error traps now, we can just use
XSetInputFocus().

gdk/x11/gdkasync.c
gdk/x11/gdkasync.h
gdk/x11/gdkdisplay-x11.c
gdk/x11/gdkwindow-x11.c

index ed598febe9aaf5276978fb222ebb454297452ca7..025b2a03b71723a553490e83bae057a57b617d26 100644 (file)
@@ -288,99 +288,6 @@ _gdk_x11_send_client_message_async (GdkDisplay           *display,
   SyncHandle();
 }
 
-static Bool
-set_input_focus_handler (Display *dpy,
-                        xReply  *rep,
-                        char    *buf,
-                        int      len,
-                        XPointer data)
-{
-  SetInputFocusState *state = (SetInputFocusState *)data;  
-
-  if (dpy->last_request_read == state->set_input_focus_req)
-    {
-      if (rep->generic.type == X_Error &&
-         rep->error.errorCode == BadMatch)
-       {
-         /* Consume BadMatch errors, since we have no control
-          * over them.
-          */
-         return True;
-       }
-    }
-  
-  if (dpy->last_request_read == state->get_input_focus_req)
-    {
-      xGetInputFocusReply replbuf;
-      xGetInputFocusReply *repl G_GNUC_UNUSED;
-      
-      if (rep->generic.type != X_Error)
-       {
-         /* Actually does nothing, since there are no additional bytes
-          * to read, but maintain good form.
-          */
-         repl = (xGetInputFocusReply *)
-           _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
-                           (sizeof(xGetInputFocusReply) - sizeof(xReply)) >> 2,
-                           True);
-       }
-
-      DeqAsyncHandler(state->dpy, &state->async);
-
-      g_free (state);
-      
-      return (rep->generic.type != X_Error);
-    }
-
-  return False;
-}
-
-void
-_gdk_x11_set_input_focus_safe (GdkDisplay             *display,
-                              Window                  window,
-                              int                     revert_to,
-                              Time                    time)
-{
-  Display *dpy;
-  SetInputFocusState *state;
-  
-  dpy = GDK_DISPLAY_XDISPLAY (display);
-
-  state = g_new (SetInputFocusState, 1);
-
-  state->dpy = dpy;
-  
-  LockDisplay(dpy);
-
-  state->async.next = dpy->async_handlers;
-  state->async.handler = set_input_focus_handler;
-  state->async.data = (XPointer) state;
-  dpy->async_handlers = &state->async;
-
-  {
-    xSetInputFocusReq *req;
-    
-    GetReq(SetInputFocus, req);
-    req->focus = window;
-    req->revertTo = revert_to;
-    req->time = time;
-    state->set_input_focus_req = dpy->request;
-  }
-
-  /*
-   * XSync (dpy, 0)
-   */
-  {
-    xReq *req;
-    
-    GetEmptyReq(GetInputFocus, req);
-    state->get_input_focus_req = dpy->request;
-  }
-  
-  UnlockDisplay(dpy);
-  SyncHandle();
-}
-
 static Bool
 list_children_handler (Display *dpy,
                       xReply  *rep,
index f9995156c7b82b2f963e2bd05f9eb2bf31d01f18..a5f67c9da74967226456bfb45cc19ba29f1f40a1 100644 (file)
@@ -54,10 +54,6 @@ void _gdk_x11_send_client_message_async (GdkDisplay            *display,
                                         XClientMessageEvent   *event_send,
                                         GdkSendXEventCallback  callback,
                                         gpointer               data);
-void _gdk_x11_set_input_focus_safe      (GdkDisplay            *display,
-                                        Window                 window,
-                                        int                    revert_to,
-                                        Time                   time);
 
 gboolean _gdk_x11_get_window_child_info (GdkDisplay       *display,
                                         Window            window,
index 2cf17ca8a6c150b82aaed17f8e9247dd8599ebc1..2911a3a6b737024561b39d6d033d09188f7e7d97 100644 (file)
@@ -1024,12 +1024,17 @@ _gdk_wm_protocols_filter (GdkXEvent *xev,
       GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
 
       /* There is no way of knowing reliably whether we are viewable;
-       * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
+       * so trap errors asynchronously around the XSetInputFocus call
        */
       if (toplevel && win->accept_focus)
-       _gdk_x11_set_input_focus_safe (display, toplevel->focus_window,
-                                      RevertToParent,
-                                      xevent->xclient.data.l[1]);
+        {
+          gdk_x11_display_error_trap_push (display);
+          XSetInputFocus (GDK_DISPLAY_XDISPLAY (display),
+                          toplevel->focus_window,
+                          RevertToParent,
+                          xevent->xclient.data.l[1]);
+          gdk_x11_display_error_trap_pop_ignored (display);
+       }
 
       return GDK_FILTER_REMOVE;
     }
index dd420885bac76db234871852e2548462c6d4a911..6cd5573a4079ab8f0fb08eb560811c4a1e6a4a48 100644 (file)
@@ -1821,11 +1821,14 @@ gdk_x11_window_focus (GdkWindow *window,
       XRaiseWindow (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window));
 
       /* There is no way of knowing reliably whether we are viewable;
-       * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
+       * so trap errors asynchronously around the XSetInputFocus call
        */
-      _gdk_x11_set_input_focus_safe (display, GDK_WINDOW_XID (window),
-                                    RevertToParent,
-                                    timestamp);
+      gdk_x11_display_error_trap_push (display);
+      XSetInputFocus (GDK_DISPLAY_XDISPLAY (display),
+                      GDK_WINDOW_XID (window),
+                      RevertToParent,
+                      timestamp);
+      gdk_x11_display_error_trap_pop_ignored (display);
     }
 }